#ifndef GAMEOBJECT_H__
#define GAMEOBJECT_H__

#include <cocos2d.h>
#include <map.h>
#include <set.h>


using namespace cocos2d;
using namespace std;

class GameObject;
class GameObjectManager{
public:
  static GameObjectManager* sharedGameObjectManager();
  GameObject* getGameObject(const char* name);
  bool  addGameObject(GameObject* go);
  void removeGameObject(GameObject* go);
private:
  static GameObjectManager *pSharedGameObjectManager;
  map<string, GameObject*> gos_;
};
//#include <>
class GameObject : public CCLayer{
public:
  static GameObject* create(const char* name);
  
  GameObject(const char* name):name_(name){}
  ~GameObject(){
    GameObjectManager::sharedGameObjectManager()->removeGameObject(this); 
  }
  void init(const char* name);
  set<string> parserPlist(const char* plistname);

  void resetCompant(const char* compantname);
  CCSprite* getCompant(const char* compantname);  
  void addCompant(const char* compantname, const char* plistname, float scale, const char* pngname=NULL); 
  void addAction(const char* compantname, const char* plistname);
  void playAction(const char* compantname, const char* actionname, const char* callback=NULL); 
  
  void playActionEx(const char* compantname, CCAction* action, const char* callback=NULL);

  void onAction(CCNode* node, void* data);

  string getName(){return name_;}
private:
  string name_;
  map<string, CCSprite*> compants_;
  map<string, CCAction*> actions_;
  set<string> callbacks_;
};




#endif
